rand — Random Values
rand
has two distinct forms. The first form is used to set the
distribution that is used to generate random values. The second form
actually generates the values. We will look at each form in turn.
- β distribution.
If the first scalar argument is a and the second scalar
argument is b, then the density of the distribution is
where B(a, b) is the binomial distribution.
- Binomial distribution.
The first scalar argument specifies the number of trials, and
the second scalar argument specifies the probability of an
event occuring in a trial.
- χ2 distribution.
The scalar argument specifies the number of degrees of
freedom.
- Default distribution.
The default distribution is a uniform distribution between 0
and 1.
- Exponential distribution.
The scalar argument specifies the mean of the distribution.
distribution.
The first scalar argument specifies the degrees of freedom present in
the numerator, and the second scalar argument specifies the degrees
of freedom in the denominator.
- Γ distribution.
If the first scalar argument is a, and the second scalar
argument is r, then the density of the distribution is:
xr-1e-ax
- Non-central χ2 distribution
The first scalar argument specifies the number of degrees of freedom,
and the second scalar argument specifies the non-centrality.
- Non-central
distribution.
The first scalar argument specifies the degrees of freedom present in
the numerator, the second scalar argument specifies the degrees
of freedom in the denominator, and the third scalar argument
specifies the non-centrality.
- Normal distribution.
The first scalar argument specifies the mean, and the second
scalar argument specifies the standard distribution.
- Poisson distribution.
The scalar argument specifies the mean of the distribution.
- Uniform distribution.
The first scalar argument specifies the lower limit, and the
second scalar argument specifies the upper limit.
The second form of the rand
function is used to produce random
variables from whatever distribution is actually selected at the time.
If you supply no arguments, then a random scalar is returned. If you
supply two scalar arguments, then a matrix is returned. The first
argument specifies the number of rows, and the second argument
specifies the number of columns. In addition, you can supply a matrix
argument, which must have two elements, where the first is the number
of rows, and the second is the number of columns. This is intended
for use with the size
function.
If srand
is not used to set the seed value, each session
will produce the same results.
Subsections